gridHelpers.ts ➔ calculateBitValue   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
export interface BoxConfig {
2
  index: number;
3
  bitValue: number;
4
  ariaLabel: string;
5
}
6
7
export function calculateBitValue(index: number): number {
8
  return Math.pow(2, 11 - index);
9
}
10
11
export function generateBoxAriaLabel(index: number, bitValue: number): string {
12
  return `Bit ${index + 1}, value ${bitValue}`;
13
}
14
15
export function generateBoxConfigs(): BoxConfig[] {
16
  const configs: BoxConfig[] = [];
17
18
  for (let i = 0; i < 12; i++) {
19
    const bitValue = calculateBitValue(i);
20
    configs.push({
21
      index: i,
22
      bitValue,
23
      ariaLabel: generateBoxAriaLabel(i, bitValue),
24
    });
25
  }
26
27
  return configs;
28
}
29
30
export function getBoxCount(): number {
31
  return 12;
32
}
33